switch to compat level 12 definition within d/control
[sven/jattach.git] / Makefile
1 JATTACH_VERSION=1.5
2
3 ifneq ($(findstring Windows,$(OS)),)
4   CL=cl.exe
5   CFLAGS=/O2 /D_CRT_SECURE_NO_WARNINGS
6   JATTACH_EXE=jattach.exe
7 else 
8   UNAME_S:=$(shell uname -s)
9   ifneq ($(findstring FreeBSD,$(UNAME_S)),)
10     CC=cc
11     CFLAGS=-O2
12     JATTACH_EXE=jattach
13   else
14     ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
15     RPM_ROOT=$(ROOT_DIR)/build/rpm
16     SOURCES=$(RPM_ROOT)/SOURCES
17     SPEC_FILE=jattach.spec
18     CC=gcc
19     CFLAGS=-O2
20     JATTACH_EXE=jattach
21   endif
22 endif
23
24 all: build build/$(JATTACH_EXE)
25
26 build:
27         mkdir -p build
28
29 build/jattach: src/jattach_posix.c
30         $(CC) $(CFLAGS) -DJATTACH_VERSION=\"$(JATTACH_VERSION)\" -o $@ $^
31
32 build/jattach.exe: src/jattach_windows.c
33         $(CL) $(CFLAGS) /DJATTACH_VERSION=\"$(JATTACH_VERSION)\" /Fobuild/jattach.obj /Fe$@ $^ advapi32.lib /link /SUBSYSTEM:CONSOLE,5.02
34
35 clean:
36         rm -rf build
37
38 $(RPM_ROOT):
39         mkdir -p $(RPM_ROOT)
40
41 rpm-dirs: $(RPM_ROOT)
42         mkdir -p $(RPM_ROOT)/SPECS
43         mkdir -p $(SOURCES)/bin
44         mkdir -p $(RPM_ROOT)/BUILD
45         mkdir -p $(RPM_ROOT)/SRPMS
46         mkdir -p $(RPM_ROOT)/RPMS
47         mkdir -p $(RPM_ROOT)/tmp
48
49 rpm: rpm-dirs build build/$(JATTACH_EXE)
50         cp $(SPEC_FILE) $(RPM_ROOT)/
51         cp build/jattach $(SOURCES)/bin/
52         rpmbuild -bb \
53                 --define '_topdir $(RPM_ROOT)' \
54                 --define '_tmppath $(RPM_ROOT)/tmp' \
55                 --clean \
56                 --rmsource \
57                 --rmspec \
58                 --buildroot $(RPM_ROOT)/tmp/build-root \
59                 $(RPM_ROOT)/jattach.spec