summaryrefslogtreecommitdiff
path: root/Makefile
blob: ac57069d484791d4da9b22459386f376bb48a20c (plain)
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
CFILES=xcwd.c
CC=gcc
CFLAGS=-Wall -Wextra -std=gnu99 -O2
LDFLAGS=-lX11
EXE=xcwd
prefix=/usr
UNAME:=$(shell uname)
O=${CFILES:.c=.o}

.PHONY: all clean distclean install
.SUFFIXES: .c .o

ifeq ($(UNAME), Linux)
    CFLAGS += -DLINUX
else
    ifeq ($(UNAME), FreeBSD)
        CFLAGS += -I/usr/local/include/ -DBSD
        LDFLAGS += -L/usr/local/lib -lutil
    else
        $(error Operating System not supported.)
    endif
endif

all: ${EXE}

clean:
	rm -vf *.o

distclean: clean
	rm -vf ${EXE}

install: ${EXE}
	install -m 0755 ${EXE} $(prefix)/bin


${EXE}: ${O}
	${CC} -o $@ ${O} ${CFLAGS} ${LDFLAGS}


.c.o:
	${CC} -c $< ${CFLAGS}