just rearranging Makefile for linux
[dcpu16] / Makefile
1 #!make
2 #
3
4 ifeq "$(origin CC)" "default"
5 CC = clang
6 endif
7
8 PROGRAMS = as-dcpu16 vm-dcpu16
9 SOURCES = common.c dcpu16.c as-dcpu16.c vm-dcpu16.c \
10 hw_clock.c hw_keyboard.c hw_lem1802.c hw_spc2000.c
11
12 CPPFLAGS += -DDEBUG
13
14 CFLAGS = -g -Wall -Wextra -pedantic -std=c99
15
16 UNAME := $(shell uname)
17 ifeq ($(UNAME),Darwin)
18 CPPFLAGS += -DHAVE_FUNOPEN
19 # libpng from system x11, libvncserver from macports
20 CPPFLAGS += -I/usr/X11/include -I/opt/local/include
21 LDFLAGS += -L/usr/X11/lib -L/opt/local/lib
22 endif
23 ifeq ($(UNAME),Linux)
24 # linux needs _GNU_SOURCE for fopencookie
25 # linux needs _XOPEN_SOURCE=600 (provided by _GNU_SOURCE) for getopt and strdup
26 CPPFLAGS += -DHAVE_FOPENCOOKIE -D_GNU_SOURCE
27 endif
28
29 CPPFLAGS += -DHAVE_LIBVNCSERVER -DHAVE_LIBPNG
30 LDFLAGS += -lvncserver -lpng -lreadline
31
32 all: $(PROGRAMS)
33
34 depend: .depend
35
36 .depend: $(SOURCES)
37 @rm -f ./.depend
38 $(CC) $(CFLAGS) -MM $^ >> ./.depend
39
40 include .depend
41
42
43 vm-dcpu16: vm-dcpu16.o dcpu16.o common.o hw_clock.o hw_keyboard.o hw_lem1802.o hw_spc2000.o
44
45 as-dcpu16: as-dcpu16.o dcpu16.o common.o
46
47 clean:
48 @rm -rf $(PROGRAMS) *.o *.dSYM .depend
49
50 check: $(PROGRAMS)