]> git.sur5r.net Git - cc65/blob - src/Makefile
Removed -std=c89.
[cc65] / src / Makefile
1 .SUFFIXES:
2
3 .PHONY: all bin $(PROGS) mostlyclean clean install avail unavail
4
5 ifeq ($(shell echo),)
6
7 PROGS = ar65  \
8         ca65  \
9         cc65  \
10         cl65  \
11         co65  \
12         da65  \
13         grc65 \
14         ld65  \
15         od65  \
16         sim65 \
17         sp65
18
19 bindir  := $(prefix)/bin
20 datadir := $(if $(prefix),$(prefix)/share/cc65,$(abspath ..))
21
22 CA65_INC = $(datadir)/asminc
23 CC65_INC = $(datadir)/include
24 LD65_LIB = $(datadir)/lib
25 LD65_OBJ = $(datadir)/lib
26 LD65_CFG = $(datadir)/cfg
27
28 CFLAGS += -MMD -MP -O -I common $(USER_CFLAGS) \
29           -Wall -Wextra -Wno-char-subscripts \
30           -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) \
31           -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG)
32
33 CFLAGS += $(if $(TRAVIS),-Werror)
34
35 LDLIBS += -lm
36
37 INSTALL = install
38
39 all bin: $(PROGS)
40
41 mostlyclean:
42         $(RM) -r ../wrk
43
44 clean:
45         $(RM) -r ../wrk ../bin
46
47 install:
48         $(if $(prefix),,$(error variable `prefix' must be set))
49         $(INSTALL) -d $(DESTDIR)$(bindir)
50         $(INSTALL) ../bin/* $(DESTDIR)$(bindir)
51
52 avail:
53         $(foreach prog,$(PROGS),$(AVAIL_recipe))
54
55 unavail:
56         $(foreach prog,$(PROGS),$(UNAVAIL_recipe))
57
58 ##########
59
60 define AVAIL_recipe
61
62 ln -s $(abspath ../bin/$(prog)) /usr/local/bin/$(prog)
63
64 endef
65
66 ##########
67
68 define UNAVAIL_recipe
69
70 $(RM) /usr/local/bin/$(prog)
71
72 endef
73
74 ##########
75
76 define OBJS_template
77
78 $1_OBJS := $$(patsubst %.c,../wrk/%.o,$$(wildcard $1/*.c))
79
80 $$($1_OBJS): | ../wrk/$1
81
82 ../wrk/$1:
83         @mkdir -p $$@
84
85 DEPS += $$($1_OBJS:.o=.d)
86
87 endef
88
89 ##########
90
91 define PROG_template
92
93 $$(eval $$(call OBJS_template,$1))
94
95 ../bin/$1$(PROGEXT): $$($1_OBJS) ../wrk/common/common.a | ../bin
96         $$(CC) $$(LDFLAGS) -o $$@ $$^ $$(LDLIBS)
97
98 $1: ../bin/$1$(PROGEXT)
99
100 endef
101
102 ##########
103
104 ../wrk/%.o: %.c
105         @echo $<
106         @$(CC) -c $(CFLAGS) -o $@ $<
107
108 ../bin:
109         @mkdir $@
110
111 $(eval $(call OBJS_template,common))
112 ../wrk/common/common.a: $(common_OBJS)
113         $(AR) r $@ $?
114
115 $(foreach prog,$(PROGS),$(eval $(call PROG_template,$(prog))))
116
117 -include $(DEPS)
118
119 else # cmd.exe
120
121 all bin:
122         msbuild cc65.sln /p:configuration=release /consoleloggerparameters:disableconsolecolor
123
124 mostlyclean:
125         $(if $(wildcard ../wrk),rmdir /s /q ..\wrk)
126
127 clean:
128         msbuild cc65.sln /p:configuration=release /consoleloggerparameters:disableconsolecolor /target:$@
129
130 install avail unavail:
131
132 endif # cmd.exe