forked from jattach/jattach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (50 loc) · 1.42 KB
/
Makefile
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
54
55
56
57
58
59
JATTACH_VERSION=1.3
ifneq ($(findstring Windows,$(OS)),)
CL=cl.exe
CFLAGS=/O2 /D_CRT_SECURE_NO_WARNINGS
JATTACH_EXE=jattach.exe
else
UNAME_S:=$(shell uname -s)
ifneq ($(findstring FreeBSD,$(UNAME_S)),)
CC=cc
CFLAGS=-O2
JATTACH_EXE=jattach
else
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
RPM_ROOT=$(ROOT_DIR)/build/rpm
SOURCES=$(RPM_ROOT)/SOURCES
SPEC_FILE=jattach.spec
CC=gcc
CFLAGS=-O2
JATTACH_EXE=jattach
endif
endif
all: build build/$(JATTACH_EXE)
build:
mkdir -p build
build/jattach: src/jattach_posix.c
$(CC) $(CFLAGS) -DJATTACH_VERSION=\"$(JATTACH_VERSION)\" -o $@ $^
build/jattach.exe: src/jattach_windows.c
$(CL) $(CFLAGS) /DJATTACH_VERSION=\"$(JATTACH_VERSION)\" /Fobuild/jattach.obj /Fe$@ $^ advapi32.lib
clean:
rm -rf build
$(RPM_ROOT):
mkdir -p $(RPM_ROOT)
rpm-dirs: $(RPM_ROOT)
mkdir -p $(RPM_ROOT)/SPECS
mkdir -p $(SOURCES)/bin
mkdir -p $(RPM_ROOT)/BUILD
mkdir -p $(RPM_ROOT)/SRPMS
mkdir -p $(RPM_ROOT)/RPMS
mkdir -p $(RPM_ROOT)/tmp
rpm: rpm-dirs build build/$(JATTACH_EXE)
cp $(SPEC_FILE) $(RPM_ROOT)/
cp build/jattach $(SOURCES)/bin/
rpmbuild -bb \
--define '_topdir $(RPM_ROOT)' \
--define '_tmppath $(RPM_ROOT)/tmp' \
--clean \
--rmsource \
--rmspec \
--buildroot $(RPM_ROOT)/tmp/build-root \
$(RPM_ROOT)/jattach.spec