Browse Source

Convert build system to GNU configure & build

This patch adds a standard configure script and converts the Makefile to
automake.  This adresses PR #30, but in a more generic way, and also
eliminates the hard coded CC variable, enabling building with clang or
even a cross compiler.

Note: this is more a proof of concept and does not include the man page
      generation.  Another pull request addresses that.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Joachim Nilsson 5 years ago
parent
commit
698732474c
6 changed files with 59 additions and 36 deletions
  1. 17
    0
      .gitignore
  2. 0
    36
      Makefile
  3. 19
    0
      Makefile.am
  4. 3
    0
      autogen.sh
  5. 13
    0
      configure.ac
  6. 7
    0
      src/Makefile.am

+ 17
- 0
.gitignore View File

@@ -1,2 +1,19 @@
1
+*~
2
+*.o
3
+.deps
1 4
 light
2 5
 light.1.gz
6
+aclocal.m4
7
+autom4te.cache
8
+compile
9
+config.h
10
+config.h.in
11
+config.log
12
+config.status
13
+configure
14
+depcomp
15
+install-sh
16
+missing
17
+stamp-h1
18
+Makefile
19
+Makefile.in

+ 0
- 36
Makefile View File

@@ -1,36 +0,0 @@
1
-PREFIX=$(DESTDIR)/usr
2
-BINDIR=$(PREFIX)/bin
3
-MANDIR=$(PREFIX)/share/man/man1
4
-
5
-CC=gcc
6
-CFLAGS=-std=c89 -O2 -pedantic -Wall -I"./include" -D_XOPEN_SOURCE=500
7
-MANFLAGS=-h -h -v -V -N
8
-
9
-HELP2MAN_VERSION := $(shell help2man --version 2>/dev/null)
10
-
11
-light: src/helpers.c src/light.c src/main.c
12
-	$(CC) $(CFLAGS) -g -o $@ $^
13
-
14
-man: light
15
-ifndef HELP2MAN_VERSION
16
-$(error "help2man is not installed")
17
-endif
18
-	help2man $(MANFLAGS) ./light | gzip - > light.1.gz
19
-
20
-install: light man
21
-	mkdir -p $(BINDIR)
22
-	cp -f ./light $(BINDIR)/light
23
-	chown root $(BINDIR)/light
24
-	chmod 4755 $(BINDIR)/light
25
-	mkdir -p $(MANDIR)
26
-	mv light.1.gz $(MANDIR)
27
-
28
-uninstall:
29
-	rm $(BINDIR)/light
30
-	rm -rf /etc/light
31
-	rm $(MANDIR)/light.1.gz
32
-
33
-clean:
34
-	rm -vfr *~ light light.1.gz
35
-
36
-.PHONY: man install uninstall clean

+ 19
- 0
Makefile.am View File

@@ -0,0 +1,19 @@
1
+SUBDIRS        = src
2
+doc_DATA       = README.md LICENSE CHANGELOG
3
+EXTRA_DIST     = README.md LICENSE CHANGELOG
4
+
5
+#
6
+# Target to run when building a release
7
+#
8
+release: distcheck
9
+	@for file in $(DIST_ARCHIVES); do	\
10
+		md5sum $$file > ../$$file.md5;	\
11
+	done
12
+	@mv $(DIST_ARCHIVES) ../
13
+	@echo
14
+	@echo "Resulting release files:"
15
+	@echo "================================================================="
16
+	@for file in $(DIST_ARCHIVES); do					\
17
+		printf "$$file    \tDistribution tarball\n";			\
18
+		printf "$$file.md5\t"; cat ../$$file.md5 | cut -f1 -d' ';	\
19
+	done

+ 3
- 0
autogen.sh View File

@@ -0,0 +1,3 @@
1
+#!/bin/sh
2
+
3
+autoreconf -W portability -visfm

+ 13
- 0
configure.ac View File

@@ -0,0 +1,13 @@
1
+AC_INIT([light], [1.2-dev], [https://github.com/haikarainen/light/issues])
2
+AM_INIT_AUTOMAKE([1.11 foreign])
3
+AM_SILENT_RULES([yes])
4
+
5
+AC_CONFIG_SRCDIR([src/light.c])
6
+AC_CONFIG_HEADER([config.h])
7
+AC_CONFIG_FILES([Makefile src/Makefile])
8
+
9
+AC_PROG_CC
10
+AC_PROG_INSTALL
11
+AC_HEADER_STDC
12
+
13
+AC_OUTPUT

+ 7
- 0
src/Makefile.am View File

@@ -0,0 +1,7 @@
1
+bin_PROGRAMS   = light
2
+light_SOURCES  = main.c light.c ../include/light.h helpers.c ../include/helpers.h
3
+light_CPPFLAGS = -I../include -D_XOPEN_SOURCE=500
4
+light_CFLAGS   = -W -Wall -Wextra -pedantic -std=c89
5
+
6
+install-exec-hook:
7
+	chmod 4755 $(DESTDIR)$(bindir)/light