Below is a proposed replacement makefile. I've updated it to automatically determine processor type and kernel version and add those into CFLAGS instead of having them on specific target commands, specified that each executable depends on the ncurses header file as well as the source file, and have filled out OS versions (bringing each distro current) and sorted them by architecture and then distro. I also corrected a minor typo in the initial comment.
ETA: code formatting, corrected awk script, added bash script to determine os version which allows for a default target
# NOTE: link the current working copy of the code to lmon.c for compilingARCH=$(uname -m)ARCHDEF=$(if$(filter ppc,$(ARCH)),POWER,$(if$(filter s390,$(ARCH)),MAINFRAME,X86))VERSION=$(shell bash -c osver.sh)KERNEL=$(shell uname -r)# Awk script prints 1 if kernel version is 2.6.18 or later, 0 if not.KERNEL_2_6_18=$(shell awk -F . '{ print (($$1 > 2) || (($$1 > 1) && (($$2 > 6) || (($$2 > 5) && ($$3 > 17))))); }'<<<$(KERNEL))CFLAGS=-g -O2 -Wall -D JFS -D GETUSER -D LARGEMEM -D $(ARCHDEF)$(if$(filter 1,$(KERNEL_2_6_18)),-D KERNEL_2_6_18,)#CFLAGS=-g -O3 -Wall -D JFS -D GETUSER -D LARGEMEMLDFLAGS=-lncurses -lm -g
FILE=lmon.c
HEADER=/usr/include/ncurses.h
default:nmon_$(ARCH)_$(VERSION)#### POWER #### POWER Red Hat Enterprise Linux - RHELnmon_ppc_rhel3 nmon_ppc_rhel4 nmon_ppc_rhel5 nmon_ppc_rhel55 nmon_ppc_rhel65:$(FILE)
gcc -o $@$(FILE)$(CFLAGS)$(LDFLAGS)nmon_ppc64_rhel3 nmon_ppc64_rhel4 nmon_ppc64_rhel5 nmon_ppc64_rhel55 nmon_ppc64_rhel65:$(FILE)
gcc -o $@$(FILE)$(CFLAGS)$(LDFLAGS)nmon_ppc_rhel7 nmon_ppc_rhel71BE nmon_ppc_rhel71LE:$(FILE)
gcc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D RHEL7
#### POWER SuSE Linux Enterprise Server - SLESnmon_ppc_sles12:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D SLES12
nmon_ppc_sles113:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D SLES113
nmon_ppc_sles112 nmon_ppc_sles11 nmon_ppc_sles10 nmon_ppc_sles9 nmon_ppc_sles8:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS)#### POWER Canonical Ubuntunmon_ppc_ubuntu140403 nmon_ppc_ubuntu1410 nmon_ppc_ubuntu1504 nmon_ppc_ubuntu1510 nmon_ppc_ubuntu1604:$(FILE)
gcc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D UBUNTU
#### POWER Canonical Ubuntu WITH NVIDIA GPUnmon_ppc_ubuntu140403_gpu:$(FILE)
gcc -o nmon_ppc_ubuntu140403_gpu $(FILE)$(CFLAGS)$(LDFLAGS) -D NVIDIA_GPU /usr/lib/nvidia-352/libnvidia-ml.so -D UBUNTU
#### MAINFRAME #### MAINFRAME SLESnmon_mainframe_sles10:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS)nmon_mainframe_sles112:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D SLES113
nmon_mainframe_rhel7:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D RHEL7
### Raspbery pinmon_arm_raspian:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D ARM
nmon_arm_ubuntu1510:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D ARM -D UBUNTU
#### AMD and Intel 32 Bit and 64 Bit (_64)#### SuSE Linux Enterprise Server - SLESnmon_x86_sles8 nmon_x86_sles9 nmon_x86_sles10:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86
nmon_x86_sles113 nmon_x86_sles114:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86 -D SLES113
nmon_x86_sles12:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86 -D SLES12
### OpenSUSEnmon_x86_opensuse10 nmon_x86_64_opensuse11 nmon_x86_64_opensuse13:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86
### Red Hat RHELnmon_x86_rhel2:
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D REREAD=1 -D X86
nmon_x86_redhat9 nmon_x86_rhel3 nmon_x86_rhel4 nmon_x86_rhel45:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86
nmon_x86_rhel5 nmon_x86_rhel52 nmon_x86_rhel54 nmon_x86_rhel58:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86
nmon_x86_rhel6 nmon_x86_rhel66:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86 -D RHEL6
nmon_x86_rhel70 nmon_x86_rhel71 nmon_x86_rhel72:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86 -D RHEL7
### CentOSnmon_x86_centos5 nmon_x86_centos52 nmon_x86_centos54 nmon_x86_centos58:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86
nmon_x86_centos6 nmon_x86_centos66:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86 -D RHEL6
nmon_x86_centos70 nmon_x86_centos71 nmon_x86_centos72:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86 -D RHEL7
### Debiannmon_x86_debian3:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86
### x86 Red Hat Fedoranmon_x86_fedora10 nmon_x86_fedora23:$(FILE)
cc -s -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86
#### x86 Canonical Ubuntunmon_x86_ubuntu810 nmon_x86_ubuntu910 nmon_x86_ubuntu134 nmon_x86_ubuntu1404 nmon_x86_ubuntu140403 nmon_x86_ubuntu140404 nmon_x86_ubuntu1410 nmon_x86_ubuntu1504 nmon_x86_ubuntu1510 nmon_x86_ubuntu1604:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86 -D UBUNTU
nmon_x86_64_ubuntu810 nmon_x86_64_ubuntu910 nmon_x86_64_ubuntu134 nmon_x86_64_ubuntu1404 nmon_x86_64_ubuntu140403 nmon_x86_64_ubuntu140404 nmon_x86_64_ubuntu1410 nmon_x86_64_ubuntu1504 nmon_x86_64_ubuntu1510 nmon_x86_64_ubuntu1604:$(FILE)
cc -o $@$(FILE)$(CFLAGS)$(LDFLAGS) -D X86 -D UBUNTU
Below is a proposed replacement makefile. I've updated it to automatically determine processor type and kernel version and add those into CFLAGS instead of having them on specific target commands, specified that each executable depends on the ncurses header file as well as the source file, and have filled out OS versions (bringing each distro current) and sorted them by architecture and then distro. I also corrected a minor typo in the initial comment.
ETA: code formatting, corrected awk script, added bash script to determine os version which allows for a default target
osver.sh:
Last edit: Jim Trigg 2016-10-17