-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmakefile.windows-gcc
55 lines (47 loc) · 1.88 KB
/
makefile.windows-gcc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
CC := gcc-3
CFLAGS += -mno-cygwin -DWIN_VERSION -DWIN_EXT_VERSION
#MAX_INCLUDES = ../../../c74support-w32/max-includes
#MSP_INCLUDES = ../../../c74support-w32/msp-includes
MAX_INCLUDES = ../../../c74support/max-includes
MSP_INCLUDES = ../../../c74support/msp-includes
INCLUDES += -I$(MAX_INCLUDES) -I$(MSP_INCLUDES)
LDFLAGS += -shared -mno-cygwin
#
# The specific Makefile for this directory might have defined MORE_SOURCE
ifdef MORE_SOURCE
$(warning MORE_SOURCE is $(MORE_SOURCE))
endif
#
# Each item of MORE_SOURCE will result in a .o file in the build dir
MORE_OBJECTS = $(patsubst %.c,$(GCC_BUILD_DIR)/%.o,$(notdir $(MORE_SOURCE)))
# Each directory of MORE_SOURCE should be in the makefile's VPATH
VPATH = $(sort $(dir $(MORE_SOURCE)))
# Each directory mentioned in MORE_SOURCE might have include files too
CFLAGS += $(addprefix -I,$(VPATH))
$(GCC_BUILD_DIR)/commonsyms.o: $(MAX_INCLUDES)/common/commonsyms.c
$(CC) -c $(CFLAGS) $(INCLUDES) $< -o $@
$(GCC_BUILD_DIR)/%.o: $(GCC_BUILD_DIR)/commonsyms.o %.c
$(CC) -c $(CFLAGS) $(INCLUDES) $< -o $@
$(GCC_BUILD_DIR)/$(OBJ).mxe: $(GCC_BUILD_DIR)/$(OBJ).o $(GCC_BUILD_DIR)/commonsyms.o $(MORE_OBJECTS) $(OBJ).def
echo ldflags $(LDFLAGS)
$(CC) -o $@ $^ -L$(MAX_INCLUDES) -L$(MSP_INCLUDES) -lMaxAPI -lMaxAudio $(LIBDIRS) $(LIBS) $(LDFLAGS)
# All of the example .def files in the Windows SDK look like this:
# ;coll.def
#
# LIBRARY coll
#
# EXPORTS
# main
# But if the object's name begins with a numeral (e.g., 2d.wave~ or 2threshattack~)
# then we're supposed to comment out the LIBRARY line.
# Grep returns status 0 if the text was found, i.e., if the object's name starts with a numeral.
# So I use sh's "if" to decide whether to write the ";" character.
#
$(OBJ).def:
echo \;$(OBJ).def > $@
@echo >> $@
@if (echo $(OBJ) | grep --quiet '^[0-9]') ; then echo -n ';' >> $@; fi
@echo LIBRARY $(OBJ) >> $@
@echo >> $@
@echo EXPORTS >> $@
@echo \ main >> $@