Browse Source

Modernize makefile: separate build dirs, single rule source

Signed-off-by: falkTX <falktx@falktx.com>
tags/v1.0.0
falkTX 5 years ago
parent
commit
8180297a0d
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 64 additions and 170 deletions
  1. +3
    -1
      .gitignore
  2. +23
    -113
      Makefile
  3. +38
    -56
      Makefile.mk

+ 3
- 1
.gitignore View File

@@ -1,4 +1,6 @@
*~
*.o
*.so
__pycache__
build32/
build64/
__pycache__/

+ 23
- 113
Makefile View File

@@ -1,122 +1,32 @@
### Generated by Winemaker
#!/usr/bin/make -f
# Makefile for WineASIO #
# --------------------- #
# Created by falkTX
#

PREFIX = /usr
SRCDIR = .
SUBDIRS =
DLLS = wineasio.dll
EXES =
all:
# $(info usage: ${0} 32|64)

# ---------------------------------------------------------------------------------------------------------------------

32:
$(MAKE) ARCH=i386 M=32

### Common settings
64:
$(MAKE) ARCH=x86_64 M=64

CEXTRA = -m32 -D_REENTRANT -fPIC -Wall -pipe
CEXTRA += -fno-strict-aliasing -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith
CEXTRA += -Werror=implicit-function-declaration
CEXTRA += $(shell pkg-config --cflags jack)
RCEXTRA =
INCLUDE_PATH = -I. -Irtaudio/include
INCLUDE_PATH += -I$(PREFIX)/include/wine
INCLUDE_PATH += -I$(PREFIX)/include/wine/windows
INCLUDE_PATH += -I$(PREFIX)/include/wine-development
INCLUDE_PATH += -I$(PREFIX)/include/wine-development/wine/windows
DLL_PATH =
LIBRARY_PATH =
LIBRARIES = -ljack
# ---------------------------------------------------------------------------------------------------------------------

ifeq ($(DEBUG),true)
CEXTRA += -O0 -DDEBUG -g -D__WINESRC__
LIBRARIES +=
else
CEXTRA += -O2 -DNDEBUG -fvisibility=hidden
endif

### wineasio.dll sources and settings

wineasio_dll_MODULE = wineasio.dll
wineasio_dll_C_SRCS = asio.c \
main.c \
regsvr.c
wineasio_dll_RC_SRCS =
wineasio_dll_LDFLAGS = -shared \
-m32 \
-mnocygwin \
$(wineasio_dll_MODULE:%=%.spec) \
-L/usr/lib32/wine \
-L/usr/lib/i386-linux-gnu/wine \
-L/usr/lib/i386-linux-gnu/wine-development \
-L/opt/wine-staging/lib \
-L/opt/wine-staging/lib/wine
wineasio_dll_DLL_PATH =
wineasio_dll_DLLS = odbc32 \
ole32 \
winmm
wineasio_dll_LIBRARY_PATH=
wineasio_dll_LIBRARIES= uuid

wineasio_dll_OBJS = $(wineasio_dll_C_SRCS:.c=.o) \
$(wineasio_dll_RC_SRCS:.rc=.res)



### Global source lists

C_SRCS = $(wineasio_dll_C_SRCS)
RC_SRCS = $(wineasio_dll_RC_SRCS)


### Tools

CC = gcc
WINECC = winegcc
RC = wrc


### Generic targets

all: rtaudio/include/asio.h $(SUBDIRS) $(DLLS:%=%.so) $(EXES:%=%.so)

### Build rules
clean::
rm -f *.o *.so
rm -rf build32 build64

.PHONY: all clean dummy
# ---------------------------------------------------------------------------------------------------------------------

$(SUBDIRS): dummy
@cd $@ && $(MAKE)

# Implicit rules

.SUFFIXES: .cpp .rc .res
DEFINCL = $(INCLUDE_PATH) $(DEFINES) $(OPTIONS)

.c.o:
$(CC) -c $(DEFINCL) $(CFLAGS) $(CEXTRA) -o $@ $<

.rc.res:
$(RC) $(RCFLAGS) $(RCEXTRA) $(DEFINCL) -fo$@ $<

# Rules for cleaning

CLEAN_FILES = y.tab.c y.tab.h lex.yy.c core *.orig *.rej \
\\\#*\\\# *~ *% .\\\#*

clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
$(RM) $(CLEAN_FILES) $(RC_SRCS:.rc=.res) $(C_SRCS:.c=.o)
$(RM) $(DLLS:%=%.so) $(EXES:%=%.so) $(EXES:%.exe=%)

$(SUBDIRS:%=%/__clean__): dummy
cd `dirname $@` && $(MAKE) clean

$(EXTRASUBDIRS:%=%/__clean__): dummy
-cd `dirname $@` && $(RM) $(CLEAN_FILES)

distclean:: clean
$(RM) asio.h

### Target specific build rules
DEFLIB = $(LIBRARY_PATH) $(LIBRARIES) $(DLL_PATH)

$(wineasio_dll_MODULE).so: $(wineasio_dll_OBJS)
$(WINECC) $(wineasio_dll_LDFLAGS) -o $@ $(wineasio_dll_OBJS) $(wineasio_dll_LIBRARY_PATH) $(DEFLIB) $(wineasio_dll_DLLS:%=-l%) $(wineasio_dll_LIBRARIES:%=-l%)
ifneq ($(ARCH),)
ifneq ($(M),)
include Makefile.mk
endif
endif

install:
if [ -d $(PREFIX)/lib32/wine ]; then cp wineasio.dll.so $(DESTDIR)$(PREFIX)/lib32/wine; else cp wineasio.dll.so $(DESTDIR)$(PREFIX)/lib/wine; fi
# ---------------------------------------------------------------------------------------------------------------------

Makefile64 → Makefile.mk View File

@@ -1,16 +1,29 @@
### Generated by Winemaker
#!/usr/bin/make -f
# Makefile for WineASIO #
# --------------------- #
# Created by falkTX
# Initially generated by winemaker
#

ifeq ($(ARCH),)
$(error incorrect use of Makefile, ARCH var is missing)
endif
ifeq ($(M),)
$(error incorrect use of Makefile, M var is missing)
endif

PREFIX = /usr
SRCDIR = .
SUBDIRS =
DLLS = wineasio.dll
EXES =

### Tools

CC = gcc
WINECC = winegcc

### Common settings

CEXTRA = -m64 -DNATIVE_INT64 -D_REENTRANT -fPIC -Wall -pipe
CEXTRA = -m$(M) -D_REENTRANT -fPIC -Wall -pipe
CEXTRA += -fno-strict-aliasing -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith
CEXTRA += -Werror=implicit-function-declaration
CEXTRA += $(shell pkg-config --cflags jack)
@@ -22,8 +35,14 @@ INCLUDE_PATH += -I$(PREFIX)/include/wine-development
INCLUDE_PATH += -I$(PREFIX)/include/wine-development/wine/windows
DLL_PATH =
LIBRARY_PATH =
LIBRARIES = -ljack
LIBRARIES = $(shell pkg-config --libs jack)

# 64bit build needs an extra flag
ifeq ($(M),64)
CEXTRA += -DNATIVE_INT64
endif

# Debug or Release
ifeq ($(DEBUG),true)
CEXTRA += -O0 -DDEBUG -g -D__WINESRC__
LIBRARIES +=
@@ -37,16 +56,18 @@ wineasio_dll_MODULE = wineasio.dll
wineasio_dll_C_SRCS = asio.c \
main.c \
regsvr.c
wineasio_dll_RC_SRCS =
wineasio_dll_LDFLAGS = -shared \
-m64 \
-m$(M) \
-mnocygwin \
$(wineasio_dll_MODULE:%=%.spec) \
-L/usr/lib64/wine \
-L/usr/lib/x86_64-linux-gnu/wine \
-L/usr/lib/x86_64-linux-gnu/wine-development \
-L/usr/lib/wine \
-L/usr/lib$(M)/wine \
-L/usr/lib/$(ARCH)-linux-gnu/wine \
-L/usr/lib/$(ARCH)-linux-gnu/wine-development \
-L/opt/wine-staging/lib \
-L/opt/wine-staging/lib/wine
-L/opt/wine-staging/lib/wine \
-L/opt/wine-staging/lib$(M) \
-L/opt/wine-staging/lib$(M)/wine
wineasio_dll_DLL_PATH =
wineasio_dll_DLLS = odbc32 \
ole32 \
@@ -54,69 +75,30 @@ wineasio_dll_DLLS = odbc32 \
wineasio_dll_LIBRARY_PATH=
wineasio_dll_LIBRARIES= uuid

wineasio_dll_OBJS = $(wineasio_dll_C_SRCS:.c=.o) \
$(wineasio_dll_RC_SRCS:.rc=.res)


wineasio_dll_OBJS = $(wineasio_dll_C_SRCS:%.c=build$(M)/%.c.o)

### Global source lists

C_SRCS = $(wineasio_dll_C_SRCS)
RC_SRCS = $(wineasio_dll_RC_SRCS)


### Tools

CC = gcc
WINECC = winegcc
RC = wrc


### Generic targets

all: rtaudio/include/asio.h $(SUBDIRS) $(DLLS:%=%.so) $(EXES:%=%.so)
all: rtaudio/include/asio.h $(DLLS:%=build$(M)/%.so)

### Build rules

.PHONY: all clean dummy

$(SUBDIRS): dummy
@cd $@ && $(MAKE)
.PHONY: all

# Implicit rules

.SUFFIXES: .cpp .rc .res
DEFINCL = $(INCLUDE_PATH) $(DEFINES) $(OPTIONS)

.c.o:
build$(M)/%.c.o: %.c
@$(shell mkdir -p build$(M))
$(CC) -c $(DEFINCL) $(CFLAGS) $(CEXTRA) -o $@ $<

.rc.res:
$(RC) $(RCFLAGS) $(RCEXTRA) $(DEFINCL) -fo$@ $<

# Rules for cleaning

CLEAN_FILES = y.tab.c y.tab.h lex.yy.c core *.orig *.rej \
\\\#*\\\# *~ *% .\\\#*

clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
$(RM) $(CLEAN_FILES) $(RC_SRCS:.rc=.res) $(C_SRCS:.c=.o)
$(RM) $(DLLS:%=%.so) $(EXES:%=%.so) $(EXES:%.exe=%)

$(SUBDIRS:%=%/__clean__): dummy
cd `dirname $@` && $(MAKE) clean

$(EXTRASUBDIRS:%=%/__clean__): dummy
-cd `dirname $@` && $(RM) $(CLEAN_FILES)

distclean:: clean
$(RM) asio.h

### Target specific build rules
DEFLIB = $(LIBRARY_PATH) $(LIBRARIES) $(DLL_PATH)

$(wineasio_dll_MODULE).so: $(wineasio_dll_OBJS)
build$(M)/$(wineasio_dll_MODULE).so: $(wineasio_dll_OBJS)
$(WINECC) $(wineasio_dll_LDFLAGS) -o $@ $(wineasio_dll_OBJS) $(wineasio_dll_LIBRARY_PATH) $(DEFLIB) $(wineasio_dll_DLLS:%=-l%) $(wineasio_dll_LIBRARIES:%=-l%)

install:
if [ -d $(PREFIX)/lib/wine ]; then cp wineasio.dll.so $(DESTDIR)$(PREFIX)/lib/wine; else cp wineasio.dll.so $(DESTDIR)$(PREFIX)/lib/wine; fi

Loading…
Cancel
Save