view agent/core/Makefile @ 1102:8757e35030f2

Add user ID to VmInfo and display in clients This commit adds user ID information to the VmInfo Pojo, which is gathered by SystemBackend. The UID for a VM is collected by parsing /proc/${pid}/status, and we then get the username for the UID from the native function getpwuid_r. Both the vm-info command and the VM Overview tab of the Swing GUI now show the user under Process Information. I took inspiration from the id Unix program for the formatting, which is "uid(username)". The native component of this commit is added to agent-core for use by system-backend, this was done on request by Mario since agent-core already has a native component for getting the hostname. I made this component an OSGi service primarily to hide its implementation details. Reviewed-by: omajid, jerboaa Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-May/006674.html
author Elliott Baron <ebaron@redhat.com>
date Tue, 21 May 2013 12:43:17 -0400
parents 7a2c0ac3dba1
children
line wrap: on
line source

CC         = gcc
JAVAH      = javah
MYCFLAGS   = -c -Wall -fPIC
MYLDFLAGS  = -fPIC -shared
COPY       = cp -a

CLASSPATH  = target/classes/
TARGET_DIR = target

INCLUDE    = -I $(TARGET_DIR) -I $(JAVA_HOME)/include/ -I $(JAVA_HOME)/include/linux
HOSTNAME_SOURCES    = src/main/native/HostName.c
HOSTNAME_TARGET     = $(TARGET_DIR)/HostName.c
HOSTNAME_OBJECTS    = $(HOSTNAME_TARGET:.c=.o)

HOSTNAME_EXECUTABLE = libHostNameWrapper.so

USERNAME_SOURCES    = src/main/native/UserNameUtilImpl.c
USERNAME_TARGET     = $(TARGET_DIR)/UserNameUtilImpl.c
USERNAME_OBJECTS    = $(USERNAME_TARGET:.c=.o)

USERNAME_EXECUTABLE = libUserNameUtilWrapper.so

.PHONY:
JNI_LIST = com.redhat.thermostat.utils.hostname.HostName\
 com.redhat.thermostat.utils.username.internal.UserNameUtilImpl

$(JNI_LIST):
	$(JAVAH) -force -classpath $(CLASSPATH) -d $(TARGET_DIR) $(JNI_LIST)

all: $(JNI_LIST) init $(HOSTNAME_SOURCES) $(HOSTNAME_EXECUTABLE) $(USERNAME_SOURCES) $(USERNAME_EXECUTABLE)

.PHONY:
init:
	$(COPY) $(HOSTNAME_SOURCES) $(HOSTNAME_TARGET)
	$(COPY) $(USERNAME_SOURCES) $(USERNAME_TARGET)

$(HOSTNAME_EXECUTABLE): $(HOSTNAME_OBJECTS)
	$(CC) $(HOSTNAME_OBJECTS) -o $(TARGET_DIR)/$@ $(MYLDFLAGS) $(LDFLAGS)
	
$(USERNAME_EXECUTABLE): $(USERNAME_OBJECTS)
	$(CC) $(USERNAME_OBJECTS) -o $(TARGET_DIR)/$@ $(MYLDFLAGS) $(LDFLAGS)

.c.o:
	$(CC) $(MYCFLAGS) $(CFLAGS) $(INCLUDE) $< -o $@

clean-lib:
	rm $(TARGET_DIR)/$(HOSTNAME_EXECUTABLE)
	rm $(TARGET_DIR)/$(USERNAME_EXECUTABLE)
	
clean-obj:
	rm $(HOSTNAME_OBJECTS) $(HOSTNAME_TARGET)
	rm $(USERNAME_OBJECTS) $(USERNAME_TARGET)
	
clean: clean-obj clean-lib